package juice;

import juice.DI$multiInterface.module.ServiceModule;
import juice.DI$multiInterface.module.ServiceModule2Static;
import juice.DI$multiInterface.module.ServiceModuleOfNoAnnotation;
import junit.framework.TestCase;

import com.google.inject.Guice;
import com.google.inject.Injector;

public class TestMultiInterface extends TestCase
{

	/**
	 * 通过自定义注解实现接口多实现
	 */
	public void testMultiInterface()
	{
		Injector injector = Guice.createInjector(new ServiceModule());
		ServiceModule module = injector.getInstance(ServiceModule.class);
		module.homeService.execute();
		module.schoolsService.execute();
	}

	/**
	 * 静态注入
	 */
	public void testMultiInterface2Static()
	{
		Guice.createInjector(new ServiceModule2Static());
		ServiceModule2Static.homeService.execute();
		ServiceModule2Static.schoolsService.execute();
	}

	/**
	 * 使用Named的代替自己手写注解
	 */
	public void testMultiInterfaceOfNoAnnotation()
	{
		Guice.createInjector(new ServiceModuleOfNoAnnotation());
		ServiceModuleOfNoAnnotation.homeService.execute();
		ServiceModuleOfNoAnnotation.schoolsService.execute();
	}

}
